#ifndef _DATABASE_H_
#define _DATABASE_H_

namespace databaselib
{
	namespace io
	{
		class Database
		{
		public:
			Database() : m_connect( false ){};
			virtual ~Database(){};
			
			virtual bool connect() = NULL;
			virtual bool release()  = NULL;

			virtual bool executeSQL(const char *query )  = NULL;
			virtual bool fetch()  = NULL;

			virtual Database& operator >> ( char *out ) = NULL;
			virtual Database& operator >> ( char &out ) = NULL;
			virtual Database& operator >> ( bool &out ) = NULL;
			virtual Database& operator >> ( unsigned int &out ) = NULL;
			virtual Database& operator >> ( int &out ) = NULL;
			virtual Database& operator >> ( unsigned long &out ) = NULL;
			virtual Database& operator >> ( __int64 &out ) = NULL;
			virtual Database& operator >> ( float &out ) = NULL;
			virtual Database& operator >> ( short &out ) = NULL;
			virtual Database& operator >> ( unsigned short &out ) = NULL;
			virtual Database& operator >> ( struct tm &out ) = NULL;
			virtual Database& operator >> ( SmallDate &out ) = NULL;
			virtual Database& operator >> ( unsigned char &out ) = NULL;

			bool isConnect() { return ( m_connect ) ; } ;
		protected:
			bool m_isConnect;
		};

		class AgentDB
		{
		public:
			AgentDB();
			virtual ~AgentDB();

			virtual void release() = NULL;

			Database *getDataBase();
			bool checkDBConnect( Database *database );

		public:
			virtual bool initializeDataBaseEnv( char *dataBaseIP, char *defaultDB, char *userid, char *password ) = NULL;
			virtual bool releaseDataBaseEnv() = NULL;

			virtual Database *getNewDBInstance() = NULL;

			static void releaseDB();
		protected:
			utillib::stl::QueueList < databaselib::io::Database * > m_databaseList;
		};
	};
};

#endif